<?php

class Application_Model_Form_AddUser extends Zend_Form {

    public function __construct() {
        parent::__construct();

        $username = new Zend_Form_Element_Text('username');
        $username->setLabel('Имя пользователя')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->addValidator('AlNum')//Только латиница
                ->addValidator('Db_NoRecordExists', false, array('table' => 'users', 'field' => 'username'))
                ->addFilter('StringTrim')
                ->addFilter('StripTags');
        $email = new Zend_Form_Element_Text('email');
        $email->setLabel('E-mail')
                ->setRequired(true)
                ->addValidator('EmailAddress')
                ->addValidator('Db_NoRecordExists', false, array('table' => 'users', 'field' => 'email'));
        $password = new Zend_Form_Element_Password('password');
        $password->setLabel('Пароль')
                ->setRequired(true)
                ->addValidator('NotEmpty');
        $password_confirm = new Zend_Form_Element_Password('password_confirm');
        $password_confirm->setLabel('Пароль еще раз')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->addValidator('Passwordconfirm')
                ->addPrefixPath('App_Validator', 'app/validator', 'validate');
        $submit = new Zend_Form_Element_submit('send');

        $this->addElements(array($username, $password, $password_confirm, $submit));
         $this->addDisplayGroup(array('username', 'password', 'password_confirm','send'), 'message', array('legend' => ''));
    }

}

?>